// JavaScript Document

var jq = jQuery.noConflict();
jQuery(function(){



	jq.getJSON("menuServlet",function (data) {
		console.log(data);
		var li = ``;
		var left_li =``;

		jq(data).each(function (i,e) {
			//处理头部导航
			li +=`<li><a href="Food.html">${e.classifyName}</a></li>`;
			var sec_li='';
			var three_li='';
			jq(e.menuList).each(function (sub_i,sub_e) {
				//嵌套循环二级菜单
				if (e.menuList.length==1 || sub_i==e.menuList.length-1){  //处理最后的那个/
					sec_li +=  sub_e.classifyName ;
				}else{
					sec_li +=  sub_e.classifyName +' / ';
				}

				//嵌套循环三级菜单
				jq(sub_e.menuList).each(function (three_i,three_e) {
					three_li += ` <a href="#"> ${three_e.classifyName} </a> `;
				})
			})
			left_li +=`<li>
                        <div class="fj">
                            <span class="n_img"><span></span><img src="images/nav${i+1}.png" /></span>
                            <span class="fl">${e.classifyName}</span>
                        </div>
                        <div class="zj">
                            <div class="zj_l">
                                <div class="zj_l_c">
                                    <h2>${sec_li}</h2>
                                    <a href="#">${three_li}</a></div>
                            </div> 
                        </div>
                    </li>`

			//处理左边的分类导航
		});
		console.log(left_li);
		jq(".menu_r").eq(0).html(li);
		jq(".leftNav ul").eq(0).html(left_li);

		jq(".leftNav ul li").hover(
			function(){
				jq(this).find(".fj").addClass("nuw");
				jq(this).find(".zj").show();
			}
			,
			function(){
				jq(this).find(".fj").removeClass("nuw");
				jq(this).find(".zj").hide();
			}
		)

	});
	//jq(".leftNav ul li").hover(

})


